﻿using System;

namespace CommLib
{
    public class CalendarEntry
    {
        public readonly static int FIELD_COUNT = 6;

	    private readonly string mTitle;
	    private readonly DateTime mBegin;
	    private readonly DateTime mEnd;
	    private readonly string mDescription;
	    private readonly bool mIsAllDay;
        private readonly string mLocation;

        public CalendarEntry(String[] data, int firstIdx) 
        {
		    if (data.Length - firstIdx < FIELD_COUNT)
			    throw new ArgumentException("Too few data fields!");

		    mTitle = data[firstIdx++];
            mBegin = BluetoothMessage.parseDateTime(long.Parse(data[firstIdx++]));
            mEnd = BluetoothMessage.parseDateTime(long.Parse(data[firstIdx++]));
            mDescription = data[firstIdx++];
            mIsAllDay = bool.Parse(data[firstIdx++]);
            mLocation = data[firstIdx++];
	    }

	    public string getTitle() 
        {
		    return mTitle;
	    }

        public DateTime getBeginDate()
        {
            return mBegin;
        }

        public DateTime getEndDate()
        {
            return mEnd;
        }

        public string getDescription()
        {
            return mDescription;
        }

        public bool isAllDay()
        {
            return mIsAllDay;
        }

        public string getLocation()
        {
            return mLocation;
        }
    }
}
